#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
@Author: 李吉凯
@Email: lijk34925@hundsun.com
@Time: 2021/11/29 19:19
@File: test_dataload.py
"""
import json
import requests
from Frame.Log import log_init
file = '../log/DataLoad.log'
logger = log_init(file)

class TestDataLoad():
    def setup(self):
        logger.info('test setup!')
        self.data = {'corp_no': '328676979F0009',
                'corp_name': '首约科技（北京）有限公司',
                'land_level': 53,
                'force': True,
                'whole': False,
                'operator_code': '1',
                'user_token': '1'
                }

    def teardown(self):
        logger.info('test teardown!')

    def loadData(self, data):
        head = {'Content-Type': 'application/json;charset=UTF-8'}
        res = requests.get('http://btg.com:9002/gefrm-irv-server/common/landingEnterpriseData', params=data,
                           headers=head)
        logger.info(f"res:{res}")
        body = json.loads(res.text)
        logger.info(f"res_text:{body}")
        return_code = body.get('return_code')
        logger.info(f"return_code:{return_code}")
        assert return_code == 0
        successList = body.get('result').get('successList')
        if successList:
            for line in successList:
                logger.info(line)
        else:
            logger.warn(f'successList:{successList}')
        errorList = body.get('result').get('errorList')
        if errorList:
            for line in errorList:
                logger.warn(line)
        else:
            logger.warn(f'errorList:{errorList}')
        return res

    # 变更记录--pass
    def test_land_level_1(self):
        new_dict = {"land_level": 1}
        logger.info(f'testing land_level: {new_dict["land_level"]}')
        self.data.update(new_dict)
        res = self.loadData(self.data)
        return res

    # 软件著作权、作品著作权、专利列表、商标列表
    def test_land_level_2(self):
        new_dict = {"land_level": 2}
        logger.info(f'testing land_level: {new_dict["land_level"]}')
        self.data.update(new_dict)
        res = self.loadData(self.data)
        return res

    # 股权质押
    def test_land_level_3(self):
        new_dict = {"land_level": 3}
        logger.info(f'testing land_level: {new_dict["land_level"]}')
        self.data.update(new_dict)
        res = self.loadData(self.data)
        return res

        # 分红情况
    def test_land_level_3_2(self):
        new_dict = {'corp_no': '10130538000009', 'corp_name': '王府井集团股份有限公司', "land_level": 3}
        logger.info(f'testing land_level: {new_dict["land_level"]}')
        self.data.update(new_dict)
        res = self.loadData(self.data)
        return res

    # 裁判文书
    def test_land_level_22(self):
        new_dict = {"land_level": 22}
        logger.info(f'testing land_level: {new_dict["land_level"]}')
        self.data.update(new_dict)
        res = self.loadData(self.data)
        return res

    # 上市公告
    def test_land_level_34(self):
        new_dict = {'corp_no': '10130538000009', 'corp_name': '王府井集团股份有限公司', "land_level": 34}
        logger.info(f'testing land_level: {new_dict["land_level"]}')
        self.data.update(new_dict)
        res = self.loadData(self.data)
        return res